package chapter20;

import java.util.*;

public class TestIterator {
    public static void main(String[] args) {
        Collection<Student> student = new ArrayList<>();
        student.add(new Student("1班", "胖虎", 86));
        student.add(new Student("2班", "小夫", 87));
        student.add(new Student("2班", "冲哥", 89));
        student.add(new Student("1班", "胖子", 113));

        // 创建迭代器
        Iterator<Student> iterator = student.iterator();

        for (Student x : student) {
            if (x.id == "1班") {
                x.score += 10;
            } else {
                System.out.println("二班学生不给予加分！");
            }
            if (x.score > 100) {
                x.score = 100;
                System.out.println("最终成绩不能超过100！");
            }
            System.out.println(x.toString());
        }
        System.out.println();
    }

}
